package com.lancoo.answer.util.paperUtils.fragmentUtils.child;

import android.text.TextUtils;
import android.util.Log;

import androidx.fragment.app.Fragment;

import com.lancoo.answer.model.ConstantBean;
import com.lancoo.answer.model.bean.Child;
import com.lancoo.answer.model.bean.Ques;
import com.lancoo.answer.ui.child.lookReview.ChildClozeLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildFillLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildMatchLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildSelectLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.CompositionLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.PassageDictationLookReviewFragment;
import com.lancoo.answer.ui.child.lookReview.ChildReadMatchLookReviewFragment;
import com.lancoo.answer.ui.ques.WaitToDockFragment;
import com.lancoo.answer.view.fragment.manual.ManualAnswerLookingFragment;
import com.lancoo.answer.view.fragment.paragraphSort.ParagraphSortingChildLookingFragment;
import com.lancoo.answer.view.fragment.webquesBody.WebQuesBodyLookingFragment;
import com.lancoo.answer.view.fragment.translate.TranslateChapterAnswerLookingFragment;

/**
 * Created by pengmi on 2022/2/20 11:49
 * Description:小题互评状态状态fragment加载
 */
public class ChildMuteValueteFragmentUtils {

    public static Fragment loadChildmuteValueteFragment(Ques ques,
                                                        int typeIndex,
                                                        int quesIndex,
                                                        int childIndex,
                                                        int defaultLoadIndex){
        Log.e("666","互评");
        String genreID=ques.getGenreID();
        String typeNo=ques.getTypeNo();
        Child child=ques.getChildList().get(0);
        switch (genreID) {
            case "38"://句子英译中
            case "25"://英译中
            case "40"://句子中译英
            case "26"://中译英
                return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "43"://段落匹配
                return ChildMatchLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
            case "42"://阅读匹配
                return ChildReadMatchLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "20"://选词填空
                int childSize = ques.getChildList().size();
                int itemSize = ques.getChildList().get(0).getItemList().size();
                if (childSize > itemSize) {//句子场景
                    return ChildFillLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                } else {//短文场景
                    return WebQuesBodyLookingFragment.Companion.loadFragment(typeIndex, quesIndex, 0, defaultLoadIndex);
                }
            case "45"://多项对应
                return ParagraphSortingChildLookingFragment.Companion.loadFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
        }
        switch (typeNo) {
            case "f"://作文题
                return CompositionLookReviewFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
            case "W"://短文听写
            case "X"://阅读简答
                if (ConstantBean.Companion.getTaskControlBean().isManu()){
                    return ManualAnswerLookingFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
                }else {
                    return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }
            case "S"://听力填空
//                    return QueseListenFillFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
                return WebQuesBodyLookingFragment.Companion.loadFragment(typeIndex, quesIndex, childIndex, defaultLoadIndex);
            case "C"://语法选择，完形填空，对话选择
                return ChildClozeLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "D"://阅读理解，阅读判断
                return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "E": //听力选择
                if (TextUtils.isEmpty(child.getChildAsk())) {
                    return ChildClozeLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                } else {
                    return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }
            case "N":
                return ChildFillLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case "g": //翻译题
                return TranslateChapterAnswerLookingFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
        }
        int childAnswerType = child.getChildAnswerType();
        switch (childAnswerType) {
            case 1:
                return ChildSelectLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
            case 2:
            case 4:
                if (ConstantBean.Companion.getTaskControlBean().isManu()){
                    return ManualAnswerLookingFragment.loadQueseFragment(typeIndex, quesIndex, childIndex);
                }else {
                    return PassageDictationLookReviewFragment.loadChildFragment(typeIndex, quesIndex, childIndex);
                }

            default:
                return new WaitToDockFragment();
        }
    }
}
